<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/all.css" />
		<link rel="stylesheet" type="text/css" href="index_iconfont/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="css/second-list.css" />
		<script src="js/api.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/Cookie.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<div id="scoll-top">
			<div class="wraper1">
				<div class="header-a">
					<a href="index.html">
						<div class="logo">暖岛</div>
					</a>
					<div class="header-search">
						<input type="search" class="header-search-input" id="J_search-input" placeholder="请输入关键字搜索">
						<i></i>
					</div>
					<span class="header-a_hint">每日10点上新&nbsp;&nbsp;&nbsp;&nbsp;满249元包邮</span>
					<div class="index-weiboshare m-hidden" id="J_index-weibo-plugins1"><iframe width="121" scrolling="no" height="24" frameborder="0" src="http://widget.weibo.com/relationship/followbutton.php?language=zh_cn&amp;width=136&amp;height=24&amp;uid=2093879035&amp;style=2&amp;btn=red&amp;dpc=1"></iframe></div>

					<div class="nav-mynuandao">
						<div class="mini-cart">
							<span class="iconfont icon-gouwuche"></span>
							<span class="cart-word">购物车</span>
							<span class="cart-num">0</span>
						</div>
						<li class="site-nav-pipe m-hidden">|</li>
						<div class="user-login">
							<a href="reg-login.html">登录 | 注册</a>
						</div>
						<div id="user-information">
							<span class="user-img"></span>
							<span class="user-name"></span>
							<p class="user-icon"></p>
							<div class="user-nuandao">
								<div class="arrow"></div>
								<ul class="user-nuandao-list">
									<li>
										<a href="javascript:;">我的订单</a>
									</li>
									<li>
										<a href="javascript:;">未付款订单</a>
									</li>
									<li><span class="user-nuandao-num">1</span>
										<a href="javascript:;">我的代金券</a>
									</li>
									<li>
										<a href="javascript:;">我的评价</a>
									</li>
									<li>
										<a href="javascript:;">我的最爱</a>
									</li>
									<li>
										<a href="javascript:;">我的作品</a>
									</li>
									<li>
										<a href="javascript:;">修改密码</a>
									</li>
									<li class="log-out" id="log-out">
										<a href="javascript:;">登出</a>
									</li>
								</ul>

							</div>
						</div>
					</div>
				</div>
			</div>
			<!--2-->
			<div class="wraper2">
				<div class="container">
					<ul class="main-nav">
						<li>
							<a href="javascript:;" class="nav-special">大家喜欢</a>
						</li>
						<li>
							<a href="javascript:;" class="open-second-nav second-nav-1">女装服饰</a>
						</li>
						<li>
							<a href="javascript:;" class="open-second-nav second-nav-2">男装服饰</a>
						</li>
						<li>
							<a href="javascript:;" class="open-second-nav second-nav-3">美容健康</a>
						</li>
						<li>
							<a href="javascript:;" class="open-second-nav second-nav-4">家居创意</a>
						</li>
						<li>
							<a href="javascript:;" class="open-second-nav second-nav-5">数码户外</a>
						</li>
						<li>
							<a href="javascript:;" class="open-second-nav second-nav-6">限时暖价</a>
						</li>
						<li>
							<a href="javascript:;" class="nav-special">精选品牌</a>
						</li>

					</ul>
					<div class="wraper2-1">
						<div class="wraper2-1_cont cont-first"><i class="iconfont icon-haoyou icon-color"></i>邀请好友立送20元</div>
						<div class="wraper2-1_cont cont-second">
							<div class="mobile-link">
								<i class="iconfont icon-mobile icon-color">
								
							</i> 手机版
							</div>
							<!--hover-->
							<div class="hover-mobile">
								<img src="img/mobile.jpg" />
								<div class="arrow2"></div>
							</div>
						</div>
						<div class="wraper2-1_cont cont-third">
							<div class="iconfont icon-weixin">
							</div>
							<!--hover-->
							<div id="" class="hover-weixin">
								<img src="img/weixin.jpg" />
								<div class="arrow3"></div>
							</div>
						</div>

					</div>
					<!---->
					<!--2级菜单-->
					<div class="wrapper-second-nav">
						<div class="second-nav">
							<div class="second-nav-l">
								<h4>逛分类</h4>
								<ul>
									<li>
										<a href="javascript:;">
											<!--新品T恤-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--T恤背心-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--卫衣-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--衬衫罩衫-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--毛衣针织-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--连衣裙-->
										</a>
									</li>
								</ul>
								<ul>
									<li>
										<a href="javascript:;">
											<!--半身裙-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--外套-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--牛仔裤-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--裤装-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--泳衣-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--內衣-->
										</a>
									</li>
								</ul>
								<ul>
									<li>
										<a href="javascript:;">
											<!--袜子-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--鞋靴-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--箱包-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--饰品-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--配件-->
										</a>
									</li>
									<li>
										<a href="javascript:;">
											<!--限时暖价-->
										</a>
									</li>
								</ul>
							</div>
							<div class="second-nav-r">

								<h4>特别推荐</h4>
								<div class="second-nav-r-bottom">
									<ul>
										<li>
											<a href="javascript:;">暖岛独家</a>
										</li>
										<li>
											<a href="javascript:;">买手精选</a>
										</li>
										<li>
											<a href="javascript:;">编辑推荐</a>
										</li>
										<li>
											<a href="javascript:;">岛民最爱</a>
										</li>
										<li>
											<a href="javascript:;">本月星座</a>
										</li>
										<li>
											<a href="javascript:;">LookBook</a>
										</li>
									</ul>
									<div class="second-nav-r-img">
										<a href="javascript:;"><img /></a>
										<a href="javascript:;"><img /></a>
										<a href="javascript:;"><img /></a>
										<a href="javascript:;"><img /></a>
										<a href="javascript:;"><img /></a>
										<a href="javascript:;"><img /></a>
									</div>
								</div>
							</div>
						</div>
					</div>
					<!---->
				</div>

			</div>
		</div>
		<!--baoqilai-->
		<!--空白-->
		<!--baoqilai-->
		<!--空白-->
		<div class="header-none">

		</div>
		<!--网页头部结束-->

		<!--更多难看的商品-->
		<div class="wrapper-4">
			<div class="more-product">
				<h3 class="more-product-header">
					<div id="tab-btn" class="tab-btn-block">
						隐藏选单 
					</div>
					<div id="sort-method">
						<div id="sort-default">排序：默认</div>
						<ul id="sort-hidden">
							<li onclick="sort(0,'pid')">默认</li>
							<li onclick="sort(1,'pprice')">价格由低至高</li>
							<li onclick="sort(0,'price')">价格由高至低</li>
							<li onclick="sort(1,'pid')">商品人气</li>
						</ul>
					</div>
					<p>共464件商品</p>
				</h3>
				<div class="cont-list">
					<div id="more-choose">
						<div>
							<div class="more-choose-1">
								<a href="javascript:;" class="more-first">外套</a>
								<div class="more-choose-ul-1">
									<a href="javascript:;"><span></span>其他</a>
									<a href="javascript:;"><span></span>风衣</a>
									<a href="javascript:;"><span></span>棉服</a>
									<a href="javascript:;"><span></span>毛呢大衣</a>
									<a href="javascript:;"><span></span>夹克</a>
									<a href="javascript:;"><span></span>牛仔</a>
									<a href="javascript:;"><span></span>羽绒服</a>
									<a href="javascript:;"><span></span>西装</a>
								</div>
							</div>
							<div class="more-choose-2">
								<a href="javascript:;" class="more-first">选择颜色</a>
								<div class="more-choose-ul-2">
									<a href="javascript:;"></a>
									<a href="javascript:;"></a>
									<a href="javascript:;"></a>
									<a href="javascript:;"></a>
									<a href="javascript:;"></a>
									<a href="javascript:;"></a>
								</div>
							</div>
							<!--33-->
							<div class="more-choose-1 more-choose-2">
								<a href="javascript:;" class="more-first">设计师品牌</a>
								<div class="more-choose-ul-1">
									<a href="javascript:;"><span></span>ourhour</a>
									<a href="javascript:;"><span></span>安妮陈（非自营）</a>
									<a href="javascript:;"><span></span>自觉</a>
									<a href="javascript:;"><span></span>猫头鹰说Hoo~</a>
									<a href="javascript:;"><span></span>ZZ、SEVEN</a>
									<a href="javascript:;"><span></span>角色制造</a>
									<a href="javascript:;"><span></span>UIUADA</a>
									<a href="javascript:;"><span></span>香港Krop</a>
									<a href="javascript:;"><span></span>ZIBtextile</a>
									<a href="javascript:;"><span></span>两视一听</a>
									<a href="javascript:;"><span></span>琴哩</a>
									<a href="javascript:;"><span></span>Mengyao0528</a>
									<a href="javascript:;"><span></span>油果日记</a>
									<a href="javascript:;"><span></span>FYW STUDIO</a>
								</div>
							</div>
						</div>
					</div>
					<ul class="more-product-list">
						<!--ajax请求加载更多-->
					</ul>
				</div>
			</div>
		</div>
		<!--相同的底部-->

		<!--8888底部-->
		<div class="wrapper8">

			<div id="footer">

				<div id="goTop">^</div>

				<div id="footer-color">
					<div class="footer-a">
						<div class="footer-a-left">
							<ul>
								<li>
									<a href="javascript:;">逛逛暖岛</a>
								</li>
								<li>
									<a href="javascript:;">登录注册</a>
								</li>
								<li>
									<a href="javascript:;">下单及支付</a>
								</li>
								<li>
									<a href="javascript:;">使用代金券</a>
								</li>
								<li>
									<a href="javascript:;">找回密码</a>
								</li>
							</ul>
							<!--2-->
							<ul>
								<li>
									<a href="javascript:;">订单详情</a>
								</li>
								<li>
									<a href="javascript:;">查询订单</a>
								</li>
								<li>
									<a href="javascript:;">追踪物流</a>
								</li>
								<li>
									<a href="javascript:;">配送费用</a>
								</li>
								<li>
									<a href="javascript:;">配送时间</a>
								</li>
							</ul>
							<!--3-->
							<ul>
								<li>
									<a href="javascript:;">退货换货</a>
								</li>
								<li>
									<a href="javascript:;">退还规则</a>
								</li>
								<li>
									<a href="javascript:;">退换方式</a>
								</li>
								<li>
									<a href="javascript:;">退款时间</a>
								</li>
								<li>
									<a href="javascript:;">运费报销</a>
								</li>
							</ul>
							<!--4-->
							<ul>
								<li>
									<a href="javascript:;">关于暖岛</a>
								</li>
								<li>
									<a href="javascript:;">暖岛故事</a>
								</li>
								<li>
									<a href="javascript:;">合作机会</a>
								</li>
								<li>
									<a href="javascript:;">加入暖岛</a>
								</li>
								<li>
									<a href="javascript:;">联系我们</a>
								</li>
							</ul>
						</div>
						<div class="footer-a-right">
							<h4>订阅电子报</h4>
							<div class="footer-email">
								<input class="input" type="email" name="news-email" id="news-email" placeholder="请输入邮箱地址">
								<a herf="javascript:;" id="newsbook-btn" class="iconfont icon-youxiang-"><i></i></a>
							</div>
							<!--图标-->

							<!--图标-->
						</div>
					</div>

				</div>
				<!--color-->
				<!--footer-->

				<div class="footer-b">
					<div class="anquan">
						<img src="img/anquanrenz.jpg" />
					</div>
					<ul class="footer-list">
						<li>
							<a href="javascript:;">使用条款</a>
						</li>
						<li>
							<a href="javascript:;">暖岛APP</a>
						</li>
						<li>
							<a href="javascript:;">友情链接</a>
						</li>
					</ul>
					<p>Nuandao.com 北京暖岛网络信息科技有限公司 © 2011-2016 All rights reserved 京ICP备13034710号-1 | 京公网安备11010102001819号 | 执照号：91110108584425669B | 营业执照信息 | 食品经营许可证：
					</p>

					<a class="icon-315 m-hidden" href="http://www.315online.com.cn/member/315140028.html" title="安全交易认证" target="_blank"></a>
					<div class="work m-hidden">
						周一至周五9:30-18:00<br> 客服热线：021-50276566
					</div>
				</div>
				<!--footer-b-->

				<!--联系客服-->
				<div style="position: fixed; z-index: 279; bottom: 5px; right: 5px;">
					<a href="javascript:;" onclick="easemobim.bind({tenantId: 27912})">
						<img id="easemob-icon" src="http://img2.nuandaocdn.com/Public/images/easemob-icon.png">
					</a>
				</div>
				<!--联系客服-->
			</div>
		</div>
	</body>
	<script src="js/secondNav.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/all.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		//console.log(location.search)

		//更多商品推荐?pagesize=20&pagenum=4

		var data = {
			pagesize: 20,
			pagenum: 5
		}
		moreGoods(data, function() {
			//点击图片跳转到详情
			$('.sale-leaf a').click(function() {
				//console.log(1)
				let getPid = this.getAttribute('pid');
				this.href = `detail.html?pid=${getPid}`
			})
		})

		
		
		
		var list = []
		function moreGoods(dat, cbfn) {
			var allGoodsApi = api.allgoodsListApi
			
			$.ajax({
				url: allGoodsApi,
				type: 'get',
				data: dat, //设置参数
				success: function(res) {
					//console.log(JSON.parse(res).data);
					list = JSON.parse(res).data;
					renderHTML(list)
					if(cbfn) {
						cbfn()
					}
				},
				error: function(error) {
					console.log(error);
				}
			});;

		} /*moregoods函数*/

		//监听滚轮到达底部自动加载更多
		$(document).scroll(function() {
			//console.log($(document).scrollTop())
			if($(document).scrollTop() - $(document).height() + $(window).height() >= -20) {
				//距离底部20

				data.pagenum++;
				console.log(data)
				moreGoods(data, function() {
					$('.sale-leaf a').click(function() {
						//console.log(1)
						let getPid = this.getAttribute('pid');
						this.href = `detail.html?pid=${getPid}`
					})
				});
				var scrollX = $(document).scrollTop();
				$(document).scrollTop(scrollX - 200)
			}

		})

		//点击时让div显示和隐藏之间切换
		$('#tab-btn').click(function() {
			if($('#more-choose').css('display') == 'block') {
				$('#more-choose').css({
					display: 'none'
				})
				$('.more-product-list').css({
					width: '100%'
				})
				$('#tab-btn').html('显示选单')
				$('#tab-btn').attr('class', 'tab-btn-none')
			} else {
				$('#more-choose').css({
					display: 'block'
				})
				$('.more-product-list').css({
					width: '1008px'
				})
				$('#tab-btn').html('隐藏选单')
				$('#tab-btn').attr('class', 'tab-btn-block')
			}
		})
		//点击标题，隐藏列表
		$('.more-first').click(function() {

			$(this).next().slideToggle()
			//$("div:first").nextAll().addClass("after");
		})

		//点击排序
		function sort(type, name) {
			// 			list.sort(function(a, b) {
			// 				if (type == 1) {
			// 					return a.price - b.price
			// 				} else {
			// 					return b.price - a.price
			// 				}
			// 			})
			console.log(1)
			
		
			//renderHTML(list)
			
		
			var myList=[]
			$.ajax({
				url:api.allgoodsListApi,
				type: 'get',
				data: data, //设置参数
				success: function(res) {
					//console.log(JSON.parse(res).data);
					myList = JSON.parse(res).data;
					console.log(myList)
					myList.sort((a, b) => type == 1 ? a[name] - b[name] : b[name] - a[name])
					myList.sort((a, b) => type == 1 ? a[name] - b[name] : b[name] - a[name])
					
					console.log(myList)
					$('.more-product-list').html('')
					renderHTML(myList)
					
				},
				error: function(error) {
					console.log(error);
				}
			});;
			//$('#sort-hidden').css({display:'none'})

		}

		//renderHTML函数的封装
		function renderHTML(data) {
			var moreHtml = '';
			for(let i = 0; i < data.length; i++) {
				let moreObj = data[i];

				moreHtml += `
								<div class="sale-leaf">
						<a class="sale-leaf_imga" href="javascript:;" title="${moreObj.pname}" target="_blank" pid="${moreObj.pid}">
							<div class="sale-leaf_subtitle">${moreObj.pdesc}
							</div>
							<img class="currentImage lazyload-img" data-original="${moreObj.pimg}" src="${moreObj.pimg}" style="display: inline;">
						</a>
						<div class="sale-leaf_info">
							<a class="col-4" href="javascript:;" target="_blank" pid="${moreObj.pid}">${moreObj.pname}
							</a>
							<div class="clearfix">
								<strong><span>￥${moreObj.pprice}</span> | <span class="through">￥${Number(moreObj.pprice)+23}</span></strong>
							</div>
							
						</div>
					</div>
					 			`
			} /*for循环结束*/
			$('.more-product-list').append(moreHtml)
		}
	</script>

</html>